home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pdox693.zip / TI538.ASC < prev    next >
Text File  |  1992-09-03  |  11KB  |  463 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                                NUMBER  :  538
  9.   VERSION  :  All
  10.        OS  :  DOS
  11.      DATE  :  September 3, 1992                        PAGE  :  1/7
  12.  
  13.     TITLE  :  Why, How and When to Use the PAL Wait Command
  14.  
  15.  
  16.  
  17.  
  18.   ┌───────────────────────────────────────────────────────────────┐
  19.   │                                                               │
  20.   │ This Technical Information Sheet is a teaching aid for        │
  21.   │ people who are new to PAL.  It contains PAL code to demon-    │
  22.   │ strate a model solution to a specific problem and is not      │
  23.   │ intended to represent a complete programming solution.        │
  24.   │ Programmers who use this code must take responsibility for    │
  25.   │ debugging and developing their application.  Debugging and    │
  26.   │ developing applications is considered consulting and is       │
  27.   │ beyond the scope of technical support.                        │
  28.   │                                                               │
  29.   └───────────────────────────────────────────────────────────────┘
  30.   Note: before working with this Technical Information Sheet,
  31.   change to the directory containing the sample tables
  32.   (C:\PDOX35\SAMPLE by default) and make sure that the CUSTOMER,
  33.   PRODUCTS, and ORDERS tables are available.
  34.  
  35.   If you play a script containing the command:
  36.  
  37.     EDIT "Customer"
  38.  
  39.   the table Customer will be on the workspace in Edit mode, and you
  40.   will be able to edit it as usual.  However, you are no longer
  41.   under script control while you edit the table.  Without the WAIT
  42.   command, problems can arise,  One such problem is illustrated in
  43.   the following script:
  44.  
  45.     WHILE true
  46.       SHOWMENU
  47.         "Edit"  : "Edit Customer",
  48.         "Leave" : "Exit script"
  49.       TO Choice
  50.  
  51.       SWITCH
  52.         CASE Choice = "Edit"  :
  53.           EDIT "Customer"
  54.         CASE Choice = "Leave" :
  55.           QUITLOOP
  56.       ENDSWITCH
  57.     ENDWHILE
  58.  
  59.   After you play this script, and choose the Edit option, you find
  60.   yourself right back at the menu.  What happened?  The script
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                                NUMBER  :  538
  75.   VERSION  :  All
  76.        OS  :  DOS
  77.      DATE  :  September 3, 1992                        PAGE  :  2/7
  78.  
  79.     TITLE  :  Why, How and When to Use the PAL Wait Command
  80.  
  81.  
  82.  
  83.  
  84.   continued when it encountered the EDIT command; nothing told it
  85.   to stop and accept user input.  (If you choose Edit again, you
  86.   receive a script error because the table is already in Edit
  87.   mode.)
  88.  
  89.   A PAL program continues, regardless of the state of the
  90.   workspace, until a PAL command is used to stop it.
  91.  
  92.   The solution to this problem is the WAIT command.  The rest of
  93.   this document gives a summary of WAIT, focusing on how and when
  94.   to use it.  For further information, including an explanation of
  95.   WAIT syntax, see Chapter 20 of the PAL User's Guide.  For more
  96.   information on the UNTIL clause, see TI 697 (UNTIL clause in WAIT
  97.   TABLE, RECORD, and FIELD).
  98.  
  99.   The WAIT command allows the user to interact with an on-screen
  100.   image, in Tableview or Formview, until they press a key that
  101.   allows your program to take control again.  The following script
  102.   demonstrates how to edit an on-screen image using the WAIT
  103.   command:
  104.  
  105.   ;Begin example
  106.  
  107.     WHILE true
  108.       SHOWMENU
  109.         "Edit"  : "Edit Customer",
  110.         "Leave" : "Exit script"
  111.       TO Choice
  112.  
  113.       SWITCH
  114.  
  115.         CASE Choice = "Edit"  :
  116.           EDIT "Customer"
  117.  
  118.           WAIT TABLE              ;Note this addition from
  119.           UNTIL "F2", "Esc"       ;previous example
  120.  
  121.           IF retval = "F2" THEN   ;Did user press F2?
  122.             DO_IT!                  ;Yes, save work
  123.           ELSE
  124.             CANCELEDIT              ;No, abort edit
  125.           ENDIF
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                                NUMBER  :  538
  141.   VERSION  :  All
  142.        OS  :  DOS
  143.      DATE  :  September 3, 1992                        PAGE  :  3/7
  144.  
  145.     TITLE  :  Why, How and When to Use the PAL Wait Command
  146.  
  147.  
  148.  
  149.  
  150.           CLEARIMAGE              ;Clean up workspace
  151.           CLEAR
  152.  
  153.         CASE Choice = "Leave" :
  154.           QUITLOOP                ;could be QUIT or RETURN
  155.  
  156.       ENDSWITCH
  157.  
  158.     ENDWHILE
  159.  
  160.   ; End example
  161.  
  162.   With the addition of the WAIT command, you can now view and edit
  163.   the table on the screen.  What happened?  First of all, WAIT
  164.   allows you to see the Paradox workspace, instead of the PAL
  165.   canvas.  For more information on this topic, see Chapter 13 of
  166.   the PAL User's Guide.
  167.  
  168.   Secondly, WAIT allows the user to interact with the table until
  169.   they push one of the special keys, <F2> and <ESC>.  The WAIT then
  170.   exits, and the PAL script continues normally.  The system
  171.   variable RETVAL contains the keystroke that caused WAIT to exit.
  172.   Use IF or SWITCH to determine the processing that takes place
  173.   after the WAIT.
  174.  
  175.   Use WAIT RECORD when you want your PAL application to regain
  176.   control between records.  The following example illustrates the
  177.   use of WAIT RECORD to handle key violations (Note that a network
  178.   application would require much more error checking):
  179.  
  180.   ; --- Begin example for WAIT RECORD ---
  181.  
  182.     VIEW "Customer"
  183.  
  184.     WHILE true
  185.  
  186.       WAIT TABLE                  ;This allows user to browse the
  187.                                   ;table in Main mode
  188.         PROMPT "Press F2 to exit",
  189.           "Press F9 to edit a record or Ins to add one"
  190.       UNTIL "F2", "F9", "Ins"
  191.  
  192.       IF retval = "F2" THEN
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Paradox                                NUMBER  :  538
  207.   VERSION  :  All
  208.        OS  :  DOS
  209.      DATE  :  September 3, 1992                        PAGE  :  4/7
  210.  
  211.     TITLE  :  Why, How and When to Use the PAL Wait Command
  212.  
  213.  
  214.  
  215.  
  216.         QUITLOOP
  217.  
  218.       ELSE
  219.  
  220.         COEDITKEY
  221.  
  222.         IF retval = "Ins" THEN    ;Notice how we make the same
  223.           INS                     ;ELSE work for both the <F9>
  224.         ELSE                      ;and <INS> keys with this IF.
  225.           LOCKRECORD
  226.         ENDIF
  227.  
  228.         KeyViolPrompt = ""
  229.         WHILE true
  230.  
  231.           WAIT RECORD             ;Now force the user to stay
  232.                                   ;within the record while they
  233.                                   ;edit it
  234.  
  235.             PROMPT "Press F2 to finish editing or Esc to cancel",
  236.               KeyViolPrompt
  237.           UNTIL "F2", "Esc"
  238.  
  239.           SWITCH
  240.  
  241.             CASE retval = "F2" :
  242.               UNLOCKRECORD
  243.  
  244.               IF RECORDSTATUS("KeyViol") THEN
  245.                 KeyViolPrompt = "Key Violation: modify record"
  246.  
  247.                 [] = []           ;This command takes the record
  248.                                   ;out of KeyViol status
  249.  
  250.               ELSE                ;Record must be OK
  251.                 DO_IT!
  252.                 QUITLOOP
  253.               ENDIF
  254.  
  255.             CASE retval = "Esc" :
  256.  
  257.               UNDO                ;UNDO does not normally work well
  258.                                   ;in Coedit mode, but here we only
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   PRODUCT  :  Paradox                                NUMBER  :  538
  273.   VERSION  :  All
  274.        OS  :  DOS
  275.      DATE  :  September 3, 1992                        PAGE  :  5/7
  276.  
  277.     TITLE  :  Why, How and When to Use the PAL Wait Command
  278.  
  279.  
  280.  
  281.  
  282.                                   ;modify a single record
  283.               DO_IT!
  284.               QUITLOOP
  285.  
  286.           ENDSWITCH
  287.         ENDWHILE
  288.       ENDIF
  289.     ENDWHILE
  290.  
  291.     CLEARIMAGE
  292.  
  293.   ; --- End example for WAIT RECORD ---
  294.  
  295.   WAIT FIELD provides the most complete control within an
  296.   application.  Use it for controlling cursor movement between
  297.   fields and for field validation.
  298.  
  299.   ; --- Begin example for WAIT FIELD ---
  300.  
  301.     VIEW "Products"
  302.     EDIT "Orders"
  303.  
  304.     END
  305.     DOWN
  306.  
  307.     WHILE true
  308.  
  309.       WAIT FIELD
  310.         PROMPT "Press 'F2' to finish or 'Esc' to cancel"
  311.       UNTIL "F2", "Esc", "Enter"
  312.  
  313.       SWITCH
  314.  
  315.         CASE retval = "F2" :
  316.           DO_IT!
  317.           CLEARALL
  318.           RETURN
  319.  
  320.         CASE retval = "Esc" :
  321.           CANCELEDIT
  322.           QUITLOOP                    ;Note CLEARIMAGEs at bottom
  323.  
  324.         CASE retval = "Enter" :       ;User pressed movement key to
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.   PRODUCT  :  Paradox                                NUMBER  :  538
  339.   VERSION  :  All
  340.        OS  :  DOS
  341.      DATE  :  September 3, 1992                        PAGE  :  6/7
  342.  
  343.     TITLE  :  Why, How and When to Use the PAL Wait Command
  344.  
  345.  
  346.  
  347.  
  348.                                       ;try to continue to next
  349.                                       ;field
  350.           BadQuant = false
  351.  
  352.           IF FIELD() = "Quant" THEN   ;Check which field user is in
  353.             Quant = []
  354.             StockNum = [Stock #]
  355.             UPIMAGE
  356.             MOVETO [Stock #]
  357.             LOCATE StockNum           ;Assume StockNum exists
  358.             IF Quant > [Quant] THEN   ;Make sure there is enough
  359.               BadQuant = true         ;stock available
  360.             ENDIF
  361.             MOVETO "Orders"
  362.           ENDIF
  363.  
  364.           IF NOT BadQuant THEN
  365.             ENTER
  366.           ELSE
  367.             MESSAGE "Not enough stock available"
  368.             SLEEP 1000
  369.           ENDIF
  370.  
  371.       ENDSWITCH
  372.     ENDWHILE
  373.  
  374.     CLEARIMAGE CLEARIMAGE
  375.  
  376.   ; --- End example for WAIT FIELD ---
  377.  
  378.   In summary, use WAIT to allow the user access to the workspace
  379.   and control what they do there.  WAIT TABLE allows the user
  380.   access to the entire table, WAIT RECORD restricts the user to one
  381.   record at a time, and WAIT FIELD restricts the user to one field
  382.   at a time.
  383.  
  384.   Advanced programmers with a thorough knowledge of procedures and
  385.   libraries may want to use the Data Entry Toolkit, described in
  386.   Chapter 23 of the PAL User's Guide.
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.   PRODUCT  :  Paradox                                NUMBER  :  538
  405.   VERSION  :  All
  406.        OS  :  DOS
  407.      DATE  :  September 3, 1992                        PAGE  :  7/7
  408.  
  409.     TITLE  :  Why, How and When to Use the PAL Wait Command
  410.  
  411.  
  412.  
  413.  
  414.   DISCLAIMER: You have the right to use this technical information
  415.   subject to the terms of the No-Nonsense License Statement that
  416.   you received with the Borland product to which this information
  417.   pertains.
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.